home *** CD-ROM | disk | FTP | other *** search
/ ASME's Mechanical Engine…ing Toolkit 1997 December / ASME's Mechanical Engineering Toolkit 1997 December.iso / c_lang / super_c.lzh / TYPEX.C < prev    next >
Encoding:
Text File  |  1980-01-01  |  1.1 KB  |  34 lines

  1. /*              Examples of Types of Data & Code in C
  2. */
  3.  
  4. int a,b;                        /* Uninitialized global data. */
  5.  
  6. int x = {5};                    /* Initialized global data. */
  7.  
  8. static int i;                   /* Uninitialized static data local
  9.                                    to this module. */
  10.  
  11. static int y = {9};             /* Initialized static data local to
  12.                                    this module. */
  13.  
  14. /* retNext(inc): returns the current value of a count maintained by
  15.    the routine, and then adds inc to the count. */
  16.  
  17. retNext(inc)
  18.  
  19. int inc;        /* Parameter data. */
  20.  
  21. {
  22.  static int lastinc;            /* Uninitialized static data local
  23.                                    to this function. */
  24.  static int count = {0};        /* Initialized static data local to
  25.                                    this function. */
  26.  int retValue;                  /* Automatic data. */
  27.  
  28.  lastinc = inc;                 /* Code. */
  29.  retValue = count;              /* Code. */
  30.  count += inc;                  /* Code. */
  31.  return(retValue);              /* Code. */
  32. }
  33.  
  34.